package com.jerry.provider.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.jerry.common.bean.Product;

@Mapper
public interface ProductDao {

	@Select("select * from t_product")
	public List<Product> findAll();
	
	@Select("select * from t_product where id=#{id}")
	public Product findById(Long id);
	
	@Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into t_product(name,quantity,price) values(#{name},#{quantity},#{price})")
	public boolean add(Product product);
	
	@Update("update t_product set name=#{name}, quantity=#{quantity}, price=#{price} where id=#{id}")
	public boolean update(Product product);
	
	@Delete("delete from t_product where id=#{id}")
	public void deleteById(Long id);

}
